<html>
<head>
    <meta charset="UTF-8">
    <title>api查询</title>
    <script type="text/javascript" src="static/js/jquery.min.js"></script>
    <script type="text/javascript" src="static/js/base.js"></script>
</head>
<body>

<h2>手机号码归属地查询</h2>
<div>
    <label for="phone-num">请输入手机号码：</label>
    <input id="phone-num" type="text"/>
    <input id="phone-query" type="submit" value="查询"/>
    <table id="phone-info">
        <tr>
            <td>手机号码：</td>
            <td id="phone-number"></td>
        </tr>
        <tr>
            <td>归属地：</td>
            <td id="phone-province"></td>
        </tr>
        <tr>
            <td>运营商：</td>
            <td id="phone-catName"></td>
        </tr>
        <tr>
            <td>其他：</td>
            <td id="phone-msg"></td>
        </tr>
    </table>
</div>

<h2>IP地址查询</h2>
<div>
    <label for="ip-num">请输入IP地址：</label>
    <input id="ip-num" type="text"/>
    <input id="ip-query" type="submit" value="查询"/>
    <table id="ip-info">
        <tr>
            <td>IP地址：</td>
            <td id="ip-number"></td>
        </tr>
        <tr>
            <td>国家：</td>
            <td id="ip-country"></td>
        </tr>
        <tr>
            <td>省份：</td>
            <td id="ip-province"></td>
        </tr>
        <tr>
            <td>城市：</td>
            <td id="ip-city"></td>
        </tr>
        <tr>
            <td>区域：</td>
            <td id="ip-district"></td>
        </tr>
        <tr>
            <td>运营商：</td>
            <td id="ip-carrier"></td>
        </tr>
        <tr>
            <td>其他：</td>
            <td id="ip-msg"></td>
        </tr>
    </table>
</div>

<h2>短网址转换</h2>
<div>
    <label for="url-user">请输入你要转换的网址：</label>
    <input id="url-user" type="text"/>
    <input id="url-trans" type="submit" value="转换成短网址"/>
    <table id="url-info">
        <tr>
            <td>长网址：</td>
            <td id="url-long"></td>
        </tr>
        <tr>
            <td>短网址：</td>
            <td id="url-short"></td>
        </tr>
        <tr>
            <td>二维码：</td>
            <td></td>
        </tr>
    </table>
    <img src="" id="url-img"/>
</div>

</body>

<script>
    //自动获取ip并获取信息
    $(document).ready(function () {
        API.GLOBAL.ajax('api.php', 'get', {
            app: 'MyIP'
        }, 'json', function (date) {
            $('#ip-num').val(date.ip);
            var ip = date.ip;
            API.GLOBAL.ajax('api.php', 'get', {
                app: 'QueryIP',
                ip: ip
            }, 'json', API.APPS.QUERYIP.dataCallback);
        });
    });

    //查询手机信息
    $(document).ready(function () {
        $('#phone-query').click(function () {
            var phone = $('#phone-num').val();
            API.GLOBAL.ajax('api.php', 'get', {
                app: 'QueryPhone',
                phone: phone
            }, 'json', API.APPS.QUERYPHONE.dataCallback);
        });
    });

    //查询IP信息
    $(document).ready(function () {
        $('#ip-query').click(function () {
            var ip = $('#ip-num').val();
            API.GLOBAL.ajax('api.php', 'get', {
                app: 'QueryIP',
                ip: ip
            }, 'json', API.APPS.QUERYIP.dataCallback);
        });
    });

    //转换成短网址
    $(document).ready(function () {
        $('#url-trans').click(function () {
            var url = $('#url-user').val();
            API.GLOBAL.ajax('api.php', 'get', {
                app: 'ShortURL',
                url: url
            }, 'json', API.APPS.SHORTURL.dataCallback);
        });
    });

</script>
</html>